#!/usr/bin/env bash
set -e
set -u
set -o pipefail

distro=debian9stretch

__private_print_help() {
    echo "script usage: $(basename $0)" &&\
        echo "              [-d distro]"
    __private_print_distros
}

__private_print_distros() {
    echo "supported distros:" &&\
        echo "- debian9stretch" &&\
        echo "- ubuntu1804LTS"
}

while getopts 'd:h' OPTION; do
    case "$OPTION" in
        d)
            distro=$OPTARG
            ;;
        h)
            __private_print_help
            exit
            ;;
        ?)
            __private_print_help >&2
            exit 1
            ;;
    esac
done
shift "$(($OPTIND -1))"

# NOTE: https://packages.debian.org/stretch/build-essential
#       Of course the build-essential contains some of the
#       other packages listed, but for explicit reasons
#       I will keep them. In fact, I might remove
#       build-essential later. Same for git, which one probably
#       already has when cloning the repo.
__private_deps_debian9stretch() {
    echo "Installing dependencies for Debian 9 Stretch..."
    apt install \
        build-essential \
        curl \
        emacs-goodies-el \
        emacs25 \
        filezilla \
        firefox-esr-l10n-is \
        gcc \
        git \
        gnome-disk-utility \
        keepass2 \
        make \
        openconnect \
        p7zip-full \
        pelican \
        synaptic \
        thunderbird \
        thunderbird-l10n-is \
        virtualenv \
        vlc \
        zlib1g-dev
}

# Untested and incomplete, but assumed at the time of original init for this project.
__private_deps_ubuntu1804LTS() {
    echo "Installing dependencies for Ubuntu 18.04 LTS..."
    apt install \
        build-essential \
        gcc \
        make \
        virtualenv \
        zlib1g-dev
}

__private_main() {

    # NOTE: Could either keep this as an if block or change to case.
    #       But mainly keep it encapsulated here.

    if [ "$distro" = "debian9stretch" ]; then
        __private_deps_debian9stretch
    elif [ "$distro" = "ubuntu1804LTS" ]; then
        __private_deps_ubuntu1804LTS
    elif [ "$distro" = "" ]; then
        echo "No distro set."
        __private_print_help
        exit 1
    else
        echo "Unsupported distro: $distro"
    fi
    exit
}

__private_main
